using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;
using System.Web;
using System.Threading;

namespace Data
{
	/// <summary>
	/// Strongly-typed collection for the productdetail class.
	/// </summary>
	[Serializable]
	public partial class productdetailCollection : ActiveList<productdetail, productdetailCollection> 
	{	   
		public productdetailCollection() {}

	}

	/// <summary>
	/// This is an ActiveRecord class which wraps the productdetail table.
	/// </summary>
	[Serializable]
	public partial class productdetail : ActiveRecord<productdetail>
	{
		#region .ctors and Default Settings
		
		public productdetail()
		{
		  SetSQLProps();
		  InitSetDefaults();
		  MarkNew();
		}

		
		private void InitSetDefaults() { SetDefaults(); }

		
		public productdetail(bool useDatabaseDefaults)
		{
			SetSQLProps();
			if(useDatabaseDefaults)
				ForceDefaults();
			MarkNew();
		}

		public productdetail(object keyID)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByKey(keyID);
		}

		 
		public productdetail(string columnName, object columnValue)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByParam(columnName,columnValue);
		}

		
		protected static void SetSQLProps() { GetTableSchema(); }

		
		#endregion
		
		#region Schema and Query Accessor
		public static Query CreateQuery() { return new Query(Schema); }

		
		public static TableSchema.Table Schema
		{
			get
			{
				if (BaseSchema == null)
					SetSQLProps();
				return BaseSchema;
			}

		}

		
		private static void GetTableSchema() 
		{
			if(!IsSchemaInitialized)
			{
				//Schema declaration
				TableSchema.Table schema = new TableSchema.Table("productdetail", TableType.Table, DataService.GetInstance("MyProvider"));
				schema.Columns = new TableSchema.TableColumnCollection();
				schema.SchemaName = @"";
				//columns
				
				TableSchema.TableColumn colvarProID = new TableSchema.TableColumn(schema);
				colvarProID.ColumnName = "ProID";
				colvarProID.DataType = DbType.String;
				colvarProID.MaxLength = 40;
				colvarProID.AutoIncrement = false;
				colvarProID.IsNullable = false;
				colvarProID.IsPrimaryKey = true;
				colvarProID.IsForeignKey = false;
				colvarProID.IsReadOnly = false;
				colvarProID.DefaultSetting = @"";
				colvarProID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarProID);
				
				TableSchema.TableColumn colvarName = new TableSchema.TableColumn(schema);
				colvarName.ColumnName = "Name";
				colvarName.DataType = DbType.String;
				colvarName.MaxLength = 255;
				colvarName.AutoIncrement = false;
				colvarName.IsNullable = false;
				colvarName.IsPrimaryKey = false;
				colvarName.IsForeignKey = false;
				colvarName.IsReadOnly = false;
				colvarName.DefaultSetting = @"";
				colvarName.ForeignKeyTableName = "";
				schema.Columns.Add(colvarName);
				
				TableSchema.TableColumn colvarCateDetailID = new TableSchema.TableColumn(schema);
				colvarCateDetailID.ColumnName = "CateDetailID";
				colvarCateDetailID.DataType = DbType.String;
				colvarCateDetailID.MaxLength = 40;
				colvarCateDetailID.AutoIncrement = false;
				colvarCateDetailID.IsNullable = false;
				colvarCateDetailID.IsPrimaryKey = false;
				colvarCateDetailID.IsForeignKey = false;
				colvarCateDetailID.IsReadOnly = false;
				colvarCateDetailID.DefaultSetting = @"";
				colvarCateDetailID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCateDetailID);
				
				TableSchema.TableColumn colvarProParentID = new TableSchema.TableColumn(schema);
				colvarProParentID.ColumnName = "ProParentID";
				colvarProParentID.DataType = DbType.String;
				colvarProParentID.MaxLength = 40;
				colvarProParentID.AutoIncrement = false;
				colvarProParentID.IsNullable = true;
				colvarProParentID.IsPrimaryKey = false;
				colvarProParentID.IsForeignKey = false;
				colvarProParentID.IsReadOnly = false;
				colvarProParentID.DefaultSetting = @"";
				colvarProParentID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarProParentID);
				
				TableSchema.TableColumn colvarDescription = new TableSchema.TableColumn(schema);
				colvarDescription.ColumnName = "Description";
				colvarDescription.DataType = DbType.String;
				colvarDescription.MaxLength = 500;
				colvarDescription.AutoIncrement = false;
				colvarDescription.IsNullable = true;
				colvarDescription.IsPrimaryKey = false;
				colvarDescription.IsForeignKey = false;
				colvarDescription.IsReadOnly = false;
				colvarDescription.DefaultSetting = @"";
				colvarDescription.ForeignKeyTableName = "";
				schema.Columns.Add(colvarDescription);
				
				TableSchema.TableColumn colvarVipLevel = new TableSchema.TableColumn(schema);
				colvarVipLevel.ColumnName = "VipLevel";
				colvarVipLevel.DataType = DbType.Int32;
				colvarVipLevel.MaxLength = 11;
				colvarVipLevel.AutoIncrement = false;
				colvarVipLevel.IsNullable = true;
				colvarVipLevel.IsPrimaryKey = false;
				colvarVipLevel.IsForeignKey = false;
				colvarVipLevel.IsReadOnly = false;
				colvarVipLevel.DefaultSetting = @"";
				colvarVipLevel.ForeignKeyTableName = "";
				schema.Columns.Add(colvarVipLevel);
				
				TableSchema.TableColumn colvarPrice = new TableSchema.TableColumn(schema);
				colvarPrice.ColumnName = "Price";
				colvarPrice.DataType = DbType.String;
				colvarPrice.MaxLength = 20;
				colvarPrice.AutoIncrement = false;
				colvarPrice.IsNullable = true;
				colvarPrice.IsPrimaryKey = false;
				colvarPrice.IsForeignKey = false;
				colvarPrice.IsReadOnly = false;
				colvarPrice.DefaultSetting = @"";
				colvarPrice.ForeignKeyTableName = "";
				schema.Columns.Add(colvarPrice);
				
				TableSchema.TableColumn colvarQuantity = new TableSchema.TableColumn(schema);
				colvarQuantity.ColumnName = "Quantity";
				colvarQuantity.DataType = DbType.Double;
				colvarQuantity.MaxLength = 0;
				colvarQuantity.AutoIncrement = false;
				colvarQuantity.IsNullable = true;
				colvarQuantity.IsPrimaryKey = false;
				colvarQuantity.IsForeignKey = false;
				colvarQuantity.IsReadOnly = false;
				colvarQuantity.DefaultSetting = @"";
				colvarQuantity.ForeignKeyTableName = "";
				schema.Columns.Add(colvarQuantity);
				
				TableSchema.TableColumn colvarQuantitySole = new TableSchema.TableColumn(schema);
				colvarQuantitySole.ColumnName = "QuantitySole";
				colvarQuantitySole.DataType = DbType.Double;
				colvarQuantitySole.MaxLength = 0;
				colvarQuantitySole.AutoIncrement = false;
				colvarQuantitySole.IsNullable = true;
				colvarQuantitySole.IsPrimaryKey = false;
				colvarQuantitySole.IsForeignKey = false;
				colvarQuantitySole.IsReadOnly = false;
				colvarQuantitySole.DefaultSetting = @"";
				colvarQuantitySole.ForeignKeyTableName = "";
				schema.Columns.Add(colvarQuantitySole);
				
				TableSchema.TableColumn colvarCreatedDate = new TableSchema.TableColumn(schema);
				colvarCreatedDate.ColumnName = "CreatedDate";
				colvarCreatedDate.DataType = DbType.DateTime;
				colvarCreatedDate.MaxLength = 0;
				colvarCreatedDate.AutoIncrement = false;
				colvarCreatedDate.IsNullable = true;
				colvarCreatedDate.IsPrimaryKey = false;
				colvarCreatedDate.IsForeignKey = false;
				colvarCreatedDate.IsReadOnly = false;
				colvarCreatedDate.DefaultSetting = @"";
				colvarCreatedDate.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCreatedDate);
				
				TableSchema.TableColumn colvarUpdatedDate = new TableSchema.TableColumn(schema);
				colvarUpdatedDate.ColumnName = "UpdatedDate";
				colvarUpdatedDate.DataType = DbType.DateTime;
				colvarUpdatedDate.MaxLength = 0;
				colvarUpdatedDate.AutoIncrement = false;
				colvarUpdatedDate.IsNullable = true;
				colvarUpdatedDate.IsPrimaryKey = false;
				colvarUpdatedDate.IsForeignKey = false;
				colvarUpdatedDate.IsReadOnly = false;
				colvarUpdatedDate.DefaultSetting = @"";
				colvarUpdatedDate.ForeignKeyTableName = "";
				schema.Columns.Add(colvarUpdatedDate);
				
				BaseSchema = schema;
				//add this schema to the provider
				//so we can query it later
				DataService.Providers["MyProvider"].AddSchema("productdetail",schema);
			}

		}

		#endregion
		
		#region Props
		
		  
		[XmlAttribute("ProID")]
		public string ProID 
		{
			get { return GetColumnValue<string>("ProID"); }

			set { SetColumnValue("ProID", value); }

		}

		  
		[XmlAttribute("Name")]
		public string Name 
		{
			get { return GetColumnValue<string>("Name"); }

			set { SetColumnValue("Name", value); }

		}

		  
		[XmlAttribute("CateDetailID")]
		public string CateDetailID 
		{
			get { return GetColumnValue<string>("CateDetailID"); }

			set { SetColumnValue("CateDetailID", value); }

		}

		  
		[XmlAttribute("ProParentID")]
		public string ProParentID 
		{
			get { return GetColumnValue<string>("ProParentID"); }

			set { SetColumnValue("ProParentID", value); }

		}

		  
		[XmlAttribute("Description")]
		public string Description 
		{
			get { return GetColumnValue<string>("Description"); }

			set { SetColumnValue("Description", value); }

		}

		  
		[XmlAttribute("VipLevel")]
		public int? VipLevel 
		{
			get { return GetColumnValue<int?>("VipLevel"); }

			set { SetColumnValue("VipLevel", value); }

		}

		  
		[XmlAttribute("Price")]
		public string Price 
		{
			get { return GetColumnValue<string>("Price"); }

			set { SetColumnValue("Price", value); }

		}

		  
		[XmlAttribute("Quantity")]
		public double? Quantity 
		{
			get { return GetColumnValue<double?>("Quantity"); }

			set { SetColumnValue("Quantity", value); }

		}

		  
		[XmlAttribute("QuantitySole")]
		public double? QuantitySole 
		{
			get { return GetColumnValue<double?>("QuantitySole"); }

			set { SetColumnValue("QuantitySole", value); }

		}

		  
		[XmlAttribute("CreatedDate")]
		public DateTime? CreatedDate 
		{
			get { return GetColumnValue<DateTime?>("CreatedDate"); }

			set { SetColumnValue("CreatedDate", value); }

		}

		  
		[XmlAttribute("UpdatedDate")]
		public DateTime? UpdatedDate 
		{
			get { return GetColumnValue<DateTime?>("UpdatedDate"); }

			set { SetColumnValue("UpdatedDate", value); }

		}

		
		#endregion
		
		
			
		
		//no foreign key tables defined (0)
		
		
		
		//no ManyToMany tables defined (0)
		
		#region ObjectDataSource support
		
		
		/// <summary>
		/// Inserts a record, can be used with the Object Data Source
		/// </summary>
		public static void Insert(string varProID,string varName,string varCateDetailID,string varProParentID,string varDescription,int? varVipLevel,string varPrice,double? varQuantity,double? varQuantitySole,DateTime? varCreatedDate,DateTime? varUpdatedDate)
		{
			productdetail item = new productdetail();
			
			item.ProID = varProID;
			
			item.Name = varName;
			
			item.CateDetailID = varCateDetailID;
			
			item.ProParentID = varProParentID;
			
			item.Description = varDescription;
			
			item.VipLevel = varVipLevel;
			
			item.Price = varPrice;
			
			item.Quantity = varQuantity;
			
			item.QuantitySole = varQuantitySole;
			
			item.CreatedDate = varCreatedDate;
			
			item.UpdatedDate = varUpdatedDate;
			
		
			if (HttpContext.Current != null)
				item.Save(HttpContext.Current.User.Identity.Name);
			else
				item.Save(Thread.CurrentPrincipal.Identity.Name);
		}

		
		/// <summary>
		/// Updates a record, can be used with the Object Data Source
		/// </summary>
		public static void Update(string varProID,string varName,string varCateDetailID,string varProParentID,string varDescription,int? varVipLevel,string varPrice,double? varQuantity,double? varQuantitySole,DateTime? varCreatedDate,DateTime? varUpdatedDate)
		{
			productdetail item = new productdetail();
			
				item.ProID = varProID;
				
				item.Name = varName;
				
				item.CateDetailID = varCateDetailID;
				
				item.ProParentID = varProParentID;
				
				item.Description = varDescription;
				
				item.VipLevel = varVipLevel;
				
				item.Price = varPrice;
				
				item.Quantity = varQuantity;
				
				item.QuantitySole = varQuantitySole;
				
				item.CreatedDate = varCreatedDate;
				
				item.UpdatedDate = varUpdatedDate;
				
			item.IsNew = false;
			if (HttpContext.Current != null)
				item.Save(HttpContext.Current.User.Identity.Name);
			else
				item.Save(Thread.CurrentPrincipal.Identity.Name);
		}

		#endregion
		#region Columns Struct
		public struct Columns
		{
			int i;
			 public static string ProID = @"ProID";
			 public static string Name = @"Name";
			 public static string CateDetailID = @"CateDetailID";
			 public static string ProParentID = @"ProParentID";
			 public static string Description = @"Description";
			 public static string VipLevel = @"VipLevel";
			 public static string Price = @"Price";
			 public static string Quantity = @"Quantity";
			 public static string QuantitySole = @"QuantitySole";
			 public static string CreatedDate = @"CreatedDate";
			 public static string UpdatedDate = @"UpdatedDate";
						
		}

		#endregion
	}

}

